package com.tenghui.common.enums;

import lombok.Getter;

/**
 * 认证状态枚举
 */
@Getter
public enum AuthStatus {
    NOT_SUBMITTED("0", "未提交"),
    WAITING_AUTH("1", "待认证"),
    APPROVED("2", "认证通过"),
    REJECTED("3", "已拒绝");

    private final String code;  // 字典键值
    private final String description;  // 字典标签

    AuthStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据描述获取枚举
     */
    public static AuthStatus getByDescription(String desc) {
        for (AuthStatus status : values()) {
            if (status.description.equals(desc)) {
                return status;
            }
        }
        return NOT_SUBMITTED; // 默认返回未提交
    }

    /**
     * 根据code获取枚举
     */
    public static AuthStatus getByCode(String code) {
        for (AuthStatus status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return NOT_SUBMITTED; // 默认返回未提交
    }
}